//
//  SAInventoryWarnHeaderView.m
//  yidiantong
//
//  Created by 黄志刚 on 2020/11/7.
//

#import "SAInventoryWarnHeaderView.h"
#import "SAInventoryWarningModel.h"
#import "UILabel+NSMutableAttributedString.h"

@interface SAInventoryWarnHeaderView ()

@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UIView *whiteView;

@end

@implementation SAInventoryWarnHeaderView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        [self initUI];
    }
    return self;
}

-(void)setModel:(SAInventoryWarningRecords *)model {
    _model = model;
    self.titleLab.text = [NSString stringWithFormat:@"%@,%@",model.productCode,model.productName];
}

#pragma mark - initUI
-(void)initUI {
    self.contentView.backgroundColor = kLineColor;
    [self.contentView addSubview:self.titleLab];
    [self.contentView addSubview:self.whiteView];
}

-(UIView *)whiteView {
    if (!_whiteView) {
        _whiteView = [[UIView alloc] initWithFrame:SARectMake(0, 40, kBaseScreenWidth, 34)];
        _whiteView.backgroundColor = kTextBgColor;
        NSArray *arr = @[@"颜色", @"尺码", @"库存", @"库存上限", @"库存下限"];
        NSArray *arr2 = @[@"20", @"80", @"140", @"200", @"270"];
        NSArray *arr3 = @[@"60", @"60", @"60", @"70", @"70"];
        for (int i = 0; i < arr.count; i++) {
            NSInteger x = [arr2[i] integerValue];
            NSInteger w = [arr3[i] integerValue];
            UILabel *titleLab = [[UILabel alloc] initWithFrame:SARectMake(x, 0, w, 34)];
            titleLab.text = arr[i];
            titleLab.textColor = kTextColor;
            titleLab.font = kFont(14);
            titleLab.textAlignment = NSTextAlignmentCenter;
            [_whiteView addSubview:titleLab];
        }
    }
    return _whiteView;
}

-(UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] initWithFrame:SARectMake(30, 0, 315, 40)];
        _titleLab.textColor = kBlackColor;
        _titleLab.textAlignment = NSTextAlignmentLeft;
        _titleLab.font = kFont(14);
    }
    return _titleLab;
}

@end
